//#########################################################################
//                              WackiEngie
//           Copyright (c) 2014 Marc Wacker. All rights reserved.
//#########################################################################

#include "WeTexture1D.h"

namespace WackiEngine
{

	Texture1D::Texture1D()
	{
		Texture::init(GL_TEXTURE_1D);
	}

	Texture1D::Texture1D(
		GLint format,
		GLsizei width,
		GLenum srcDataFormat,
		GLenum srcDataType,
		const GLvoid *srcData
		)
	{
		Texture::init(GL_TEXTURE_1D);
		image(0, format, width, srcDataFormat, srcDataType, srcData);
	}


	void Texture1D::image(
		GLint level,
		GLint format,
		GLsizei width,
		GLenum srcDataFormat,
		GLenum srcDataType,
		const GLvoid *srcData
		)
	{
		assert(_handle != GL_ZERO);
		glTexImage1D(_target, 0, format, width, 0, srcDataFormat, srcDataType, srcData);

		updateParameters();
	}

	void Texture1D::subImage(
		GLint level,
		GLint offset,
		GLsizei width,
		GLenum srcDataFormat,
		GLenum srcDataType,
		const GLvoid *srcData
		)
	{
		assert(_handle != GL_ZERO);
		assert(offset >= 0 && offset <= _size[0]);
		assert((offset + width) <= _size[0]);

		glTexSubImage1D(_target, level, offset, width, srcDataFormat, srcDataType, srcData);
	}

}